
package swb.api.com.repository.dto;

import lombok.Data;
import javax.persistence.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 提现记录实体类
 * 用于存储用户提现申请的相关信息，包括提现金额、手续费、状态等
 */
@Entity
@Table(name = "withdraw_records", indexes = {
        @Index(name = "idx_user_id", columnList = "user_id"),
        @Index(name = "idx_account_id", columnList = "account_id"),
        @Index(name = "idx_status", columnList = "status"),
        @Index(name = "uk_out_trade_no", columnList = "out_trade_no", unique = true),
        @Index(name = "idx_created_at", columnList = "created_at"),
        @Index(name = "idx_user_status", columnList = "user_id, status")
})
@Data
public class WithdrawRecord {
    /**
     * 主键ID，自增
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 用户ID，关联用户表
     */
    @Column(name = "user_id")
    private Long userId;

    /**
     * 账户ID，关联账户表
     */
    @Column(name = "account_id")
    private Long accountId;

    /**
     * 提现金额
     */
    private BigDecimal amount;

    /**
     * 手续费，默认为0
     */
    private BigDecimal fee = BigDecimal.ZERO;

    /**
     * 实际到账金额
     */
    @Column(name = "actual_amount")
    private BigDecimal actualAmount;

    /**
     * 提现状态
     * 0:待处理, 1:处理中, 2:成功, 3:失败
     */
    private Integer status = 0;

    /**
     * 备注信息
     */
    private String remark;

    /**
     * 外部交易号，唯一标识一次提现请求
     */
    @Column(name = "out_trade_no", unique = true)
    private String outTradeNo;

    /**
     * 创建时间
     */
    @Column(name = "created_at")
    private LocalDateTime createdAt;

    /**
     * 更新时间
     */
    @Column(name = "updated_at")
    private LocalDateTime updatedAt;
}